#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include<string.h>
#include<assert.h>
//int MyStrlen(const char* arr) {
//    int ret = 0;
//    for (char i = 0; *(arr + i) != '\0'; i++) {
//        ret = i+1;
//    }
//    return ret;
//}
//char* MyStrcpy(char* new, const char* arr2,int max) {
//    for (int i = 0; i < max; i++) {
//        if (*(arr2 + i) == '\0'&&*(new+i)=='\0') {
//            break;
//        }
//        *(new + i) = *(arr2 + i);
//    }
//    return new;
//}
int Odd(int *p) {
    if (!(*p% 2))
        return 1;
    else
        return 0;
}
int* Sequence(int* arr,int num) {
    for (int i = 0; i < num - 1; i++) {
        int count = 0;
        for (int j = 0; j < num - 1; j++) {
            if (Odd(arr + j) > Odd(arr + j + 1)) {
                *(arr + j) = *(arr + j + 1) ^ *(arr + j);
                *(arr + j + 1) = *(arr + j + 1) ^ *(arr + j);
                *(arr + j) = *(arr + j + 1) ^ *(arr + j);
                count = 1;
            }
        }
        if (count == 0)
            break;
    }
    return arr;
}
void show(const int* p, int num) {
    for (int i = 0; i < num; i++) {
        printf("%d ", *(p + i));
    }
    printf("\n");
}
int main()
{
    int arr[] = {0,-2,1,2,3,4,5,6,7,8,9};
    int num = sizeof(arr) / sizeof(arr[0]);
    printf("before: ");
    show(arr, num);
    int* p = Sequence(arr, num);
    printf("after: ");
    show(p, num);



    /*
        int i = 0;
        int arr[] = { 1,2,3,4,5,6,7,8,9,10 };*/
        /* for (i = 0; i <= 12; i++)
         {
             arr[i] = 0;
             printf("hello bit\n");
         }*/

    //char arr1[20] = "hello,world!"; 
    //char arr2[20] = "hello,bit!";
    //char new[20] = { 0 };
    //strcpy(new,arr1);
    //printf("strcpy: %s\n", new);
    //printf("MyStrcpy: %s\n",MyStrcpy(new, arr2, 20));
    //int ret = MyStrlen(arr);
    //printf("MyStrlen: %d\n", ret);
    //int str = strlen(arr);
    //printf("strlen: %d\n", str);
    //int i = 0;
    //int arr[] = { 1,2,3,4,5,6,7,8,9,10 };
    //for (i = 0; i <= 12; i++)
    //{
    //    arr[i] = 0;
    //    printf("hello bit\n");
    return 0;
}